package util.essential;

import java.io.File;
import java.io.IOException;

/**
 * @author alexis
 * This class is to get variable values from an externat plain text
 * with the following syntax:
 * 
 * ' This_is_for_make_comments
 * variable_name = variable_value
 */
public class VariableValueGetter {
	//Attributes:
	private String configurationFileName;
	//Constructor:
	/**
	 * @param configurationFileName - that is the file from where we are going to recover variable values. 
	 */
	public VariableValueGetter(String configurationFileName){
		this.configurationFileName = configurationFileName;
	}
	//Methods:
	/**
	 * This method allows to recover a "variableName" variable value.
	 * @param variableName is the variable name whose we want to know its value.
	 * @return String (variable value)
	 */
	public String getStringValue(String variableName){
		return SourceGetter.config.getVariableValue(configurationFileName, variableName);
	}
	/**
	 * This method allows to recover a conocical path from a "source" file name.
	 * @param source is the file name whose we want to know its canonical path. 
	 * @return String (a canonical path given by "source")
	 */
	public static String getSourceCanonicalPath(String source){
		File fd = new File(source);
		try {
			String canonicalPath = fd.getCanonicalPath();
			return canonicalPath;
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
}
